package nc.ui.mmpac.sumpickm.action;

import nc.ui.pubapp.uif2app.actions.DeleteAction;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.mmpac.reqpickm.enumeration.FbillStatusEnum;
import nc.vo.mmpac.sumpickm.entity.AggSumPickmVO;
import nc.vo.mmpac.sumpickm.entity.SumPickmHeadVO;

@SuppressWarnings("serial")
public class SumPickmDeleteAction extends DeleteAction {
    /**
     * @return boolean
     */
    @Override
    protected boolean isActionEnable() {

        Object[] objs = ((BillManageModel) this.getModel()).getSelectedOperaDatas();

        if (MMValueCheck.isEmpty(objs)) {
            return false;
        }

        if (objs.length > 1) {
            return true;
        }

        if (objs.length == 1) {
            AggSumPickmVO aggvo = (AggSumPickmVO) objs[0];
            SumPickmHeadVO headvo = aggvo.getParentVO();
            if (FbillStatusEnum.I_FREE.equals(headvo.getFbillstatus())) {
                return true;
            }
        }

        return false;
    }
}
